package com.globallogic.learning.kozius.actor;

/**
 * Class describes the Student actor.
 * <p/>
 * Created by sergii.koziumynskyi on 2/4/14.
 */
public final class Student extends People {
    public Student(String firstName, String lastName, int yearOfBirth, int monthOfBirth, int dayOfBirth, String placeOfBirth, boolean isCurrentExamsPassed, boolean isAllExamsPassed) {
        super(firstName, lastName, yearOfBirth, monthOfBirth, dayOfBirth, placeOfBirth);
        this.isCurrentExamsPassed = isCurrentExamsPassed;
        this.isAllExamsPassed = isAllExamsPassed;
    }

    public Student(String firstName, String lastName, boolean isCurrentExamsPassed, boolean isAllExamsPassed) {
        super(firstName, lastName);
        this.isCurrentExamsPassed = isCurrentExamsPassed;
        this.isAllExamsPassed = isAllExamsPassed;
    }

    public Student(String firstName, String lastName) {
        super(firstName, lastName);
    }

    public Student() {
    }

    public int getId() {
        return id;
    }

    public boolean isCurrentExamsPassed() {
        return isCurrentExamsPassed;
    }

    public boolean isAllExamsPassed() {
        return isAllExamsPassed;
    }

    public void setCurrentExamsPassed(boolean isCurrentExamsPassed) {
        this.isCurrentExamsPassed = isCurrentExamsPassed;
    }

    public void setAllExamsPassed(boolean isAllExamsPassed) {
        this.isAllExamsPassed = isAllExamsPassed;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Student student = (Student) o;

        if (id != student.id) return false;
        if (isAllExamsPassed != student.isAllExamsPassed) return false;
        if (isCurrentExamsPassed != student.isCurrentExamsPassed) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = (isCurrentExamsPassed ? 1 : 0);
        result = 31 * result + (isAllExamsPassed ? 1 : 0);
        result = 31 * result + id;
        return result;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", isCurrentExamsPassed=" + isCurrentExamsPassed +
                ", isAllExamsPassed=" + isAllExamsPassed +
                "} " + super.toString();
    }

    private int id;
    private boolean isCurrentExamsPassed;
    private boolean isAllExamsPassed;

    private static int nextId = 100000000;  // 1 prefix will show that it is a student

    {
        id = nextId;
        nextId++;
    }
}
